/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package rigo.ricard.pris.rs.ac.uns.dmi.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.json.JSON;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import rigo.ricard.pris.rs.ac.uns.dmi.model.CarPicture;
import rigo.ricard.pris.rs.ac.uns.dmi.model.CarPictureModel;
import rigo.ricard.pris.rs.ac.uns.dmi.model.CarPictureSoap;

import java.io.Serializable;

import java.sql.Types;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * The base model implementation for the CarPicture service. Represents a row in the &quot;car_CarPicture&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link rigo.ricard.pris.rs.ac.uns.dmi.model.CarPictureModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link CarPictureImpl}.
 * </p>
 *
 * @author Rigo Richard
 * @see CarPictureImpl
 * @see rigo.ricard.pris.rs.ac.uns.dmi.model.CarPicture
 * @see rigo.ricard.pris.rs.ac.uns.dmi.model.CarPictureModel
 * @generated
 */
@JSON(strict = true)
public class CarPictureModelImpl extends BaseModelImpl<CarPicture>
	implements CarPictureModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a car picture model instance should use the {@link rigo.ricard.pris.rs.ac.uns.dmi.model.CarPicture} interface instead.
	 */
	public static final String TABLE_NAME = "car_CarPicture";
	public static final Object[][] TABLE_COLUMNS = {
			{ "carPicureId", Types.BIGINT },
			{ "adId", Types.BIGINT },
			{ "fileName", Types.VARCHAR }
		};
	public static final String TABLE_SQL_CREATE = "create table car_CarPicture (carPicureId LONG not null primary key,adId LONG,fileName VARCHAR(75) null)";
	public static final String TABLE_SQL_DROP = "drop table car_CarPicture";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.rigo.ricard.pris.rs.ac.uns.dmi.model.CarPicture"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.rigo.ricard.pris.rs.ac.uns.dmi.model.CarPicture"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.column.bitmask.enabled.rigo.ricard.pris.rs.ac.uns.dmi.model.CarPicture"),
			true);
	public static long ADID_COLUMN_BITMASK = 1L;

	/**
	 * Converts the soap model instance into a normal model instance.
	 *
	 * @param soapModel the soap model instance to convert
	 * @return the normal model instance
	 */
	public static CarPicture toModel(CarPictureSoap soapModel) {
		if (soapModel == null) {
			return null;
		}

		CarPicture model = new CarPictureImpl();

		model.setCarPicureId(soapModel.getCarPicureId());
		model.setAdId(soapModel.getAdId());
		model.setFileName(soapModel.getFileName());

		return model;
	}

	/**
	 * Converts the soap model instances into normal model instances.
	 *
	 * @param soapModels the soap model instances to convert
	 * @return the normal model instances
	 */
	public static List<CarPicture> toModels(CarPictureSoap[] soapModels) {
		if (soapModels == null) {
			return null;
		}

		List<CarPicture> models = new ArrayList<CarPicture>(soapModels.length);

		for (CarPictureSoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}

	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.rigo.ricard.pris.rs.ac.uns.dmi.model.CarPicture"));

	public CarPictureModelImpl() {
	}

	public long getPrimaryKey() {
		return _carPicureId;
	}

	public void setPrimaryKey(long primaryKey) {
		setCarPicureId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_carPicureId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	public Class<?> getModelClass() {
		return CarPicture.class;
	}

	public String getModelClassName() {
		return CarPicture.class.getName();
	}

	@Override
	public Map<String, Object> getModelAttributes() {
		Map<String, Object> attributes = new HashMap<String, Object>();

		attributes.put("carPicureId", getCarPicureId());
		attributes.put("adId", getAdId());
		attributes.put("fileName", getFileName());

		return attributes;
	}

	@Override
	public void setModelAttributes(Map<String, Object> attributes) {
		Long carPicureId = (Long)attributes.get("carPicureId");

		if (carPicureId != null) {
			setCarPicureId(carPicureId);
		}

		Long adId = (Long)attributes.get("adId");

		if (adId != null) {
			setAdId(adId);
		}

		String fileName = (String)attributes.get("fileName");

		if (fileName != null) {
			setFileName(fileName);
		}
	}

	@JSON
	public long getCarPicureId() {
		return _carPicureId;
	}

	public void setCarPicureId(long carPicureId) {
		_carPicureId = carPicureId;
	}

	@JSON
	public long getAdId() {
		return _adId;
	}

	public void setAdId(long adId) {
		_columnBitmask |= ADID_COLUMN_BITMASK;

		if (!_setOriginalAdId) {
			_setOriginalAdId = true;

			_originalAdId = _adId;
		}

		_adId = adId;
	}

	public long getOriginalAdId() {
		return _originalAdId;
	}

	@JSON
	public String getFileName() {
		if (_fileName == null) {
			return StringPool.BLANK;
		}
		else {
			return _fileName;
		}
	}

	public void setFileName(String fileName) {
		_fileName = fileName;
	}

	public long getColumnBitmask() {
		return _columnBitmask;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
			CarPicture.class.getName(), getPrimaryKey());
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		ExpandoBridge expandoBridge = getExpandoBridge();

		expandoBridge.setAttributes(serviceContext);
	}

	@Override
	public CarPicture toEscapedModel() {
		if (_escapedModelProxy == null) {
			_escapedModelProxy = (CarPicture)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelProxyInterfaces,
					new AutoEscapeBeanHandler(this));
		}

		return _escapedModelProxy;
	}

	@Override
	public Object clone() {
		CarPictureImpl carPictureImpl = new CarPictureImpl();

		carPictureImpl.setCarPicureId(getCarPicureId());
		carPictureImpl.setAdId(getAdId());
		carPictureImpl.setFileName(getFileName());

		carPictureImpl.resetOriginalValues();

		return carPictureImpl;
	}

	public int compareTo(CarPicture carPicture) {
		long primaryKey = carPicture.getPrimaryKey();

		if (getPrimaryKey() < primaryKey) {
			return -1;
		}
		else if (getPrimaryKey() > primaryKey) {
			return 1;
		}
		else {
			return 0;
		}
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		CarPicture carPicture = null;

		try {
			carPicture = (CarPicture)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = carPicture.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
		CarPictureModelImpl carPictureModelImpl = this;

		carPictureModelImpl._originalAdId = carPictureModelImpl._adId;

		carPictureModelImpl._setOriginalAdId = false;

		carPictureModelImpl._columnBitmask = 0;
	}

	@Override
	public CacheModel<CarPicture> toCacheModel() {
		CarPictureCacheModel carPictureCacheModel = new CarPictureCacheModel();

		carPictureCacheModel.carPicureId = getCarPicureId();

		carPictureCacheModel.adId = getAdId();

		carPictureCacheModel.fileName = getFileName();

		String fileName = carPictureCacheModel.fileName;

		if ((fileName != null) && (fileName.length() == 0)) {
			carPictureCacheModel.fileName = null;
		}

		return carPictureCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(7);

		sb.append("{carPicureId=");
		sb.append(getCarPicureId());
		sb.append(", adId=");
		sb.append(getAdId());
		sb.append(", fileName=");
		sb.append(getFileName());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(13);

		sb.append("<model><model-name>");
		sb.append("rigo.ricard.pris.rs.ac.uns.dmi.model.CarPicture");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>carPicureId</column-name><column-value><![CDATA[");
		sb.append(getCarPicureId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>adId</column-name><column-value><![CDATA[");
		sb.append(getAdId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>fileName</column-name><column-value><![CDATA[");
		sb.append(getFileName());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = CarPicture.class.getClassLoader();
	private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
			CarPicture.class
		};
	private long _carPicureId;
	private long _adId;
	private long _originalAdId;
	private boolean _setOriginalAdId;
	private String _fileName;
	private long _columnBitmask;
	private CarPicture _escapedModelProxy;
}